﻿#include<iostream>
#include<string>
using  std::cout;
using std::cin;
using std::endl;
using std::string;

//基类
class Person
{
	public :
	Person(const char* name = "peter")
		//: _name(name)
	{
		
			cout << "Person()" << endl;
	}
	Person(const Person& p)
		: _name(p._name)
	{
		cout << "Person(const Person& p)" << endl;
	}
	Person& operator=(const Person& p)
	{
		cout << "Person operator=(const Person& p)" << endl;
		if (this != &p)
			_name = p._name;
		return *this;
	} 
	~Person()
	{
		cout << "~Person()" << endl;
	}
protected:
	string _name; //= "cw"; // 姓名
};

//子类
class Student : public Person
{
	public :
	Student(int num)
		: //Person(name)
		_num(num)
	{
		cout << "Student()" << endl;
	} 
	Student(const Student& s)
		: Person(s)
		, _num(s._num)
	{
		cout << "Student(const Student& s)" << endl;
	} 
	Student& operator = (const Student& s)
	{
		cout << "Student& operator= (const Student& s)" << endl;
		if (this != &s)
		{
			// 构成隐藏，所以需要显⽰调⽤
			Person::operator =(s);
			_num = s._num;
		} 
	    return * this;
	} 

	~Student()
	{
		cout << "~Student()" << endl;
	}

protected:
	int _num;
	static int a;//学号
};
int Student::a = 10; 
std::cout << Student::_num << std::endl;
int main()
{
	Student s1(18);
	Student s2(s1);
	cout << sizeof("") << endl;//空串只有一个/0字符，大小为1
	//Student s3("rose", 17);
	//s1 = s3;
	
	return 0;
}